Skip to content

Conversation

@stefanrueger
Copy link
Collaborator

@stefanrueger stefanrueger commented Oct 31, 2025

LIBAVRDUDE_EXIT was introduced to allow driver functions to tell main.c that all is done and avrdude should exit(0) indicating success. For example, processing the -x help option in a driver should exit.

There have been increasingly more situations when driver functions needed to return and suppress error messages from the caller; for these LIBAVRDUDE_EXIT was used but now avrdude wrongly indicated success to the shell when it should indicate an error.

This PR replaces LIBAVRDUDE_EXIT with LIBAVRDUDE_EXIT_FAIL or LIBAVRDUDE_EXIT_OK as appropriate indicating error or success to the shell, respectively.

This review uncovered a documentation error for -x mode=avr that actually does not exit if the programmer was already in AVR mode. Also fixed.

Please @MCUdude could you test/review this PR, in particular wrt the -x mode= cases for PICkit4/snap.

As always, you can figure out whether AVRDUDE returns success or failure to the shell with && and || as in

$ avrdude ... && echo success || echo failure

LIBAVRDUDE_EXIT was introduced to allow driver function to tell main.c
that all is done and avrdude should exit(0) indicating success. For
example, processing the -x help options in the driver should exit.

There have been increasingly more situations when the driver function
needed to return and suppress error messages from the caller; for these
LIBAVRDUDE_EXIT was used but now avrdude wrongly indicated success to the
shell when it should indicate an error.

This commit replaces LIBAVRDUDE_EXIT with LIBAVRDUDE_EXIT_FAIL or
LIBAVRDUDE_EXIT_OK as appropriate indicating error or success to the
shell, respectively.
@stefanrueger stefanrueger added bug Something isn't working documentation Improvements or additions to documentation labels Oct 31, 2025
@stefanrueger stefanrueger merged commit ada3ee8 into avrdudes:main Nov 12, 2025
15 checks passed
@stefanrueger stefanrueger deleted the libavrdude_exit branch November 12, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant